<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			.dd{
				display: none;
			}
			.active{
				background: red;
				color: white;
			}
		</style>
	</head>
	<body>
		<div id="box">
			<input class="active" type="button" value="一" />
			<input type="button" value="二" />
			<input type="button" value="三" />
			<div style="display:block;" class="dd">第一个</div>
			<div class="dd">第二个</div>
			<div class="dd">第三个</div>
		</div>
	</body>
	<script type="text/javascript">
		window.onload = function() {
			var oTab = new show("box");
		}


		function show(id) {
			var oDiv = document.getElementById(id);
			this.aBtn = oDiv.getElementsByTagName('input');
			this.aDiv = oDiv.getElementsByTagName('div');
			var i = 0;
			var _this = this;
			for (i = 0; i < this.aBtn.length; i++) {
				this.aBtn[i].index = i;
				this.aBtn[i].onclick = function() {
					_this.tab(this); 
				};
			}
		};
		show.prototype.tab = function(oBtn) {
				for (i = 0; i < this.aBtn.length; i++) {
					this.aBtn[i].className = '';
					this.aDiv[i].style.display = 'none';
				}
				oBtn.className = 'active';
				this.aDiv[oBtn.index].style.display = 'block';
		}
	</script>
</html>